<?php

include_once 'dbtable.php';

function get_all_event(pager $page,$url) {
    $sql = "select event.*,user.*,event_type.* from event,user,event_type where event.user_id = user.id and event.event_type_id = event_type.id";
    return DbTable::Paging($page, $sql, $url,15);
}
function get_event_by_id($id) {
    $sql = "select event.*,user.* from event,user where event.user_id = user.id and event.status = 1 and event.id = '{$id}'";
    return DbTable::getData($sql);
}
function them_moi_event($array) {
    if (DbTable::insert("event", $array)) {
        return true;
    }
    return false;
}

function sua_event($array, $id) {
    if (DbTable::update("event", $array, $id)) {
        return true;
    }
    return false;
}
function xoa_event($id) {
    if(DbTable::delete("event", $id)){
        return true;
    }
    return false;
}
//lay loai su kien
function get_loai_sukien() {
    $sql = "select * from event_type";
    return DbTable::getData($sql);
}
//sua
function them_moi_eventtype($array) {
    if (DbTable::insert("event_type", $array)) {
        return true;
    }
    return false;
}

function sua_eventtype($array, $id) {
    if (DbTable::update("event_type", $array, $id)) {
        return true;
    }
    return false;
}
function xoa_eventtype($id) {
    if(DbTable::delete("event_type", $id)){
        return true;
    }
    return false;
}
function get_all_event_type(pager $page,$url) {
    $sql = "select * from event_type";
    return DbTable::Paging($page, $sql, $url, 10);
}
function get_sukien_type_byid($id) {
    $sql = "select * from event_type where id = '{$id}'";
    return DbTable::JsonEncode($sql);
}
?>
